#include <iostream>
#include <string>
#include <type_traits>
#include<vector>
using namespace std;

struct node
{
    node(char& val, node* left = nullptr, node* right = nullptr)
        :_val(val)
        , _left(left)
        , _right(right)
    {
    }

    char _val;
    node* _left;
    node* _right;
};

node* creat(string& str, int& p)
{
    if (str[p] == '#')
    {
        p++;
        return nullptr;
    }

    node* root = new node(str[p++]);
    root->_left = creat(str, p);
    root->_right = creat(str, p);

    return root;
}

void Inorder(node* root)
{
    if (!root)
        return;

    Inorder(root->_left);
    cout << root->_val << " ";
    Inorder(root->_right);
}

int main()
{
    string str;
    cin >> str;
    int p = 0;
    node* root = creat(str, p);
    Inorder(root);
}